New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symfony Mailer Support #219
Conversation
Okay it seems that I have to adjust the Travis file. The mailer component does not run on php versions lower than 7.3. :/ |
Thanks @Baachi, the travis issue is not with php < 7.3 but that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but I'd like declare(strict_types=1);
removed - I'd like to follow the Symfony code standards.
@@ -0,0 +1,11 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this?
Helper/AbstractMailReporter.php
Outdated
@@ -0,0 +1,99 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove.
Helper/SymfonyMailerReporter.php
Outdated
@@ -0,0 +1,50 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
@@ -0,0 +1,65 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some changes to the travis config to better handle different symfony versions.
- Please rebase
- See https://github.com/doctrine/DoctrineBundle/blob/f6c5c7678b0ad3a6af8478e7903f3de3beeaf258/.travis.yml#L42 to see how we can add the mailer only on tests using symfony 4.3+ (I can do this step if you'd like)
try { | ||
$mailerDefinition = $container->findDefinition('mailer'); | ||
} catch (ServiceNotFoundException $e) { | ||
throw new MissingPackageException('To enable mail reporting you have to install the "swiftmailer/swiftmailer" or "symfony/mailer".'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just throw a \LogicException
here? Don't know that we need a custom exception for this.
@@ -103,6 +112,48 @@ public function testMailer() | |||
$this->assertContainerBuilderHasService('liip_monitor.reporter.swift_mailer'); | |||
} | |||
|
|||
public function testSymfonyMailer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mark as skipped if MailerInterface
does not exist.
composer.json
Outdated
@@ -42,7 +42,8 @@ | |||
"symfony/asset": "^3.4|^4.0", | |||
"symfony/templating": "^3.4|^4.0", | |||
"phpunit/phpunit": "^7.0", | |||
"symfony/finder": "^3.4|^4.0" | |||
"symfony/finder": "^3.4|^4.0", | |||
"symfony/mailer": "^4.3 || ^5.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, we'll add with travis if symfony > 4.3
ad4ec29
to
d4f508f
Compare
d4f508f
to
8a1da1e
Compare
Thanks @Baachi, I made these changes. |
} | ||
|
||
try { | ||
$mailerDefinition = $container->findDefinition('mailer'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unable to make the bundle work when I enable the mailer configuration.
I am using Symfony 4.4 (symfony/mailer 4.4, symfony/mailgun-mailer 4.4), LiipMonitorBundle 2.11.1
Regarding the Symfony documentation
In the load() method, all services and parameters related to this extension will be loaded. This method doesn't get the actual container instance, but a copy. This container only has the parameters from the actual container. After loading the services and parameters, the copy will be merged into the actual container, to ensure all services and parameters are also added to the actual container.
The container copy won't never have any mailer definition, so the exception is always raise.
Does it need a CompilerPass to load the mailer configuration instead?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Guys!
I created a symfony mailer reporter because swiftmailer is "official" dead I would think.
The SwiftMailer reporter is still available, so no BC breaks :)
#SymfonyHackday